import http from '@/libs/http'

/**
 * 添加数据
 * @param data
 */
export function createdSpecAttr(data) {
    return http({
        url: '/mall/goods/spec/attr/add',
        method: 'post',
        data
    })
}

/**
 * 根据ID删除数据(批量删除)
 * 发送复杂请求（DELETE）时设置withCredentials为true报错
 * @param data：{"idList": ["1","2"]}
 */
export function deletedSpecAttr(data) {
    return http({
        url: '/mall/goods/spec/attr/delete',
        method: 'post',
        data
    })
}

/**
 * 修改数据
 * @param data
 */
export function updatedSpecAttr(data) {
    return http({
        url: '/mall/goods/spec/attr/update',
        method: 'post',
        data
    })
}

/**
 * 根据IdD查询单条数据
 * @param id
 */
export function selectOneSpecAttr(id) {
    return http({
        url: '/mall/goods/spec/attr/get/'+id,
        method: 'get'
    })
}

/**
 * 多条件查询数据列表
 * @param query
 */
export function selectListSpecAttr(query) {
    return http({
        url: '/mall/goods/spec/attr/list',
        method: 'get',
        params: query
    })
}


/**
 * 多条件查询分页数据
 * @param query
 */
export function selectPageSpecAttr(query) {
    return http({
        url: '/mall/goods/spec/attr/page',
        method: 'get',
        params: query
    })
}

/**
 * 多条件查询分页数据
 * @param query
 */
export function selectPageAssociationCategoryAndBrandAndType(query) {
    return http({
        url: '/mall/goods/spec/attr/selectPageAssociationCategoryAndBrandAndType',
        method: 'get',
        params: query
    })
}

/**
 * 根据商品分类ID查询该分类下的规格和规格值
 * @param {*} categoryId 商品分类ID
 */
export function selectSpecAttrAndValueByCategoryId(categoryId) {
    return http({
        url: '/mall/goods/spec/attr/selectSpecAttrAndValueByCategoryId',
        method: 'get',
        params: {categoryId: categoryId}
    })
}

/**
 * 根据商品品牌ID查询该分类下的规格和规格值
 * @param {*} brandId 商品品牌ID
 */
export function selectSpecAttrAndValueByBrandId(brandId) {
    return http({
        url: '/mall/goods/spec/attr/selectSpecAttrAndValueByBrandId',
        method: 'get',
        params: {brandId: brandId}
    })
}

/**
 * 根据商品类型ID查询该分类下的规格和规格值
 * @param {*} typeId 商品类型ID
 */
export function selectSpecAttrAndValueByTypeId(typeId) {
    return http({
        url: '/mall/goods/spec/attr/selectSpecAttrAndValueByTypeId',
        method: 'get',
        params: {typeId: typeId}
    })
}